package alg20241129;

import java.util.Arrays;

public class Text {
    public int triangleNumber(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        int ret = 0;
        for (int i = n - 1; i > 1; i--) {
            for (int left = 0, right = i - 1; left < right; ) {
                if(nums[left] + nums[right] > nums[i]) {
                    ret = right - left;
                    right--;
                }else{
                    left++;
                }
            }
        }
        return ret;
    }
}
